#include "files/file_path.h"
#include "scanner/supported_files_filter.h"
#include "settings/settings.h"

#include <algorithm>

namespace Tvimeg
{
	bool SupportedFilesFilter::operator()(const File& file) const
	{
		// get the extension and make sure it is lower case
		std::string extension = file.GetExtension();
		std::transform(extension.begin(), extension.end(), extension.begin(), tolower);

		// try to find the extension in the list of supported extensions
		const Settings::StringIterator end = Settings::GetInstance().FileTypesEnd();
		return std::find(Settings::GetInstance().FileTypesBegin(), end, extension) != end;
	}
}
